home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
database
/
do1beta
/
friend.do
< prev
next >
Wrap
Text File
|
1991-07-23
|
758b
|
37 lines
/*
demo of a private method for a class
private methods are only callable from within a method for a class
*/
inherit(Nil,Temp,[]);
inherit(Nil,Temp2,[]);
/*
defining class Temp2 as a friend of class Temp
means that methods of Temp2 can access variable and private
methods of Temp
*/
friend(Temp,Temp2);
/*
define a private method for Temp
*/
private Temp::testPrivate(self)
{
? "within Temp::testPrivate()";
}
/*
define a public method for Temp2 that creates a variable of
type Temp and calls a private method for it
*/
method Temp2::test(self)
{
? "enter Temp2::test";
v = new(Temp);
testPrivate(v); % this won't work unless Temp2 is a friend of Temp !
? "exit Temp2::test";
}
v = new(Temp2);
test(v);